package com.tally.server.service;

import com.tally.server.domain.SysExpDetail;
import com.tally.server.domain.SysExpDetailExample;
import com.tally.server.dto.SysExpDetailDTO;
import com.tally.server.dto.PageDTO;
import com.tally.server.mapper.SysExpDetailMapper;
import com.tally.server.utils.CopyUtil;
import com.tally.server.utils.UUIDUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class SysExpDetailService {

    @Autowired
    private SysExpDetailMapper sysExpDetailMapper;

    /**
     * 列表查询
     */
    public List<SysExpDetailDTO> selectAll() {
        SysExpDetailExample expDetailExample = new SysExpDetailExample();
        List<SysExpDetail> sysExpDetailList = sysExpDetailMapper.selectByExample(expDetailExample);
        return CopyUtil.copyList(sysExpDetailList,SysExpDetailDTO.class);
    }

    public SysExpDetailDTO getByType(String type){
        SysExpDetailExample expDetailExample = new SysExpDetailExample();
        expDetailExample.createCriteria().andExpTypeEqualTo(type);
        List<SysExpDetail> sysExpDetailList = sysExpDetailMapper.selectByExample(expDetailExample);
        if(!CollectionUtils.isEmpty(sysExpDetailList)){
            return CopyUtil.copy(sysExpDetailList.get(0),SysExpDetailDTO.class);
        }
        return null;
    }
}
